function SignAdd_Code(address,lat,lng) {
	var buffer = new StringBuffer();
	buffer.append('<div id="signaddress" class="crmsheet border-bottom"><div class="ctitle"><div class="cname" style="padding-left:8px;">外勤地点</div><div class="require">*</div></div><div class="ctext" style="width:65%;"><input id="txt_addresses" type="text" lat="'+lat+'" lng="'+lng+'" placeholder="" value="'+address+'" readonly="readonly" style="color:#dedddd;"/></div></div>');
	buffer.append('<div class="crmsheet border-bottom"><div class="ctitle"><div class="cname" style="padding-left:8px;">拜访客户</div><div class="require">*</div></div><div class="ctext"><input id="txt_customerid" customerid="0" type="text" placeholder="填写客户名称" value=""/></div><div id="customernames" class="carrow"><a href="javascript:void(0)" style="font-size:16px; display:block; width:25px; height:30px;">选</a></div></div>');
	buffer.append('<div class="crmsheet" style="height:120px;"><div class="ctitle"><div class="cname"  style="padding-left:8px;">外勤备注</div></div><textarea id="txt_bak" placeholder="填写备注"  style="padding-left:6px; font-size:16px;"></textarea></div>');
	buffer.append('<div class="addphoto" style="width:'+(swidth-20)+'px;"><div id="img_src"><div id="addphoto" style="float:left"><img class="add" src="img/add-photo.png" style="width:'+(swidth-70)/4+'px;height:'+(swidth-70)/4+'px;" /><div class="imgload"></div></div></div></div>');
	buffer.append('<div class="border-bottom" style="float:left; width:100%; height:1px;"></div>');
	return buffer.toString();
};

var map;
var wsub;
var count=0;
var old_img="";
function Init_SignAdd(){
	get("addphoto").addEventListener('tap', function(event) {
				//get("share_context").blur();
						var btnArray = [{
							title: "拍照"
						}, {
							title: "从相册选择"
						}];
						plus.nativeUI.actionSheet({
							title: "选择照片",
							cancel: "取消",
							buttons: btnArray
						}, function(e) {
							var index = e.index;
							switch (index) {
								case 0:
									break; 
								case 1:
									var cmr = plus.camera.getCamera();
									cmr.captureImage(function(path) {
										at_count=0;
										ResizeImg("file://" + plus.io.convertLocalFileSystemURL(path),1);
										Init_ImgPreview();
									}, function(err) {});
									break;
								case 2:
									plus.gallery.pick(function(e) {
										//get("img_panel").style.display="";
										at_count=0;
										for(var i in e.files){
											ResizeImg(e.files[i],e.files.length);
											Init_ImgPreview();
								    	}
									}, function(err) {}, {filter:"image",multiple:true,maximum:9});
									break;
							}
						}); 
					}, false);
	
	get("customernames").addEventListener("tap",function(){
		myScroll3 = OpenScroll2(4,"选择客户","",function(pageindex){
										Receive_CustomerSelect(pageindex);
								},function(){
									
								},CustomerSelect_Code(),70);
								//$("#contentlist2").append(Publish_Code());
								Receive_CustomerSelect(1);
								get("find2").addEventListener("tap",function(){
				      				$("#searchicon2").hide();
	      							$("#searchicons2").show();
	      							$("#keyword2").attr("placeholder","客户名称(支持拼音)，地址");
			    					if($("keyword2").val()!="")
			    					{
			    						//WorkMate_Search();
			    					}
				      			});
	});
	
	var data = {};
	data.act = "Find_LastVisitCustomer";
	data.userid=userid;
	data.comid=comid;
	data.source=source;
	data.sign=GetSign(data.act);
	mui.getJSON(index_domain, data, function(json) {
		$("#txt_customerid").attr("customerid",json.data.CustomerID);
		$("#txt_customerid").val(json.data.CustomerName);
	});
	
	get("signaddress").addEventListener("tap",function(){
		plus.nativeUI.toast("外勤签到地点不能修改哦");
	});
};

function Save_Sign() {
        var data = {};
		upload(function(imgs){
        data.act = "Check_Sign";
        data.userid=userid;
		data.comid=comid;
		data.style=2;
        data.bak = $("#txt_bak").val();
        data.lat=$("#txt_addresses").attr("lat");
		data.lng=$("#txt_addresses").attr("lng");
		data.address=$("#txt_addresses").val();
		data.customerid=$("#txt_customerid").attr("customerid");
		data.customername=$("#txt_customerid").val().Trim();
		if(data.customername=="")
		{
			plus.nativeUI.toast("请填写或选择客户名称");
			return;
		}
		if(imgs!="")
		{
		    data.imgs=eval(imgs).join(",");
		}else
		{
		    data.imgs="";
		}
        data.source = source; 
        data.version = version;
        data.sign=GetSign(data.act);
        mui.getJSON(index_domain, data, function (json) {
            if (json.state) {
                CloseWindow();
                var html='<div class="signdialog"><div id="signclose" class="signclose">×</div><div class="signstate">外勤签到</div><div class="signoclock"><img src="img/oclock.png" width="100"/></div><div class="signtime">'+json.data.SignTime+'</div><div class="signstr">'+(json.data.SignStr+$("#txt_customerid").val())+'</div><div class="signauto">5 秒后自动关闭</div></div>';
				OpenMeng3(html,sheight/2-200);
				get("signclose").addEventListener("tap",function(){
					CloseMeng3();
				});
				tm=setInterval(AutoCloseSign,1000);
            }
        });
     });
};